<template>
  <!-- <a-drawer 
    title="订单详情"
    wrapClassName="weiben-private-drawer"
    width="70%"
    :closable="false"
    :maskClosable="true"
    :visible="visible"
    :after-visible-change="afterVisibleChange"
    @close="onClose"
  >
    <a-spin :spinning="loading">
  
    </a-spin>
  </a-drawer>  -->
<!-- 退库单 - 详情 -->
  <div v-if="visible" style="background-color: white">
    <div class="">
      <div class="">
        <span style="font-weight:bold;cursor:default;">
          <a style="cursor:default;">{{ row.no }}</a
          >单据详情
        </span>
        <!-- :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }" -->
        <div style="margin-top: 10px;">
          <a-table  :columns="columns" :data-source="list" row-key="id" :pagination="ipagination" :bordered="false"
          :rowKey="(record) => record.id"
      
          >
            <template slot="index" slot-scope="text, record, index">{{ index + 1 }}</template>
            <span slot="containerStatusscopedSlots" slot-scope="text">
              <a-tag
                :color="text === '1' ? '#daa520' : text === '2' ? '#cd5c5c' : text === '3' ? '#add8e6' : '#696969'"
                >{{ 'orderdetails_statusenum' | dictType(text) }}</a-tag
              >
            </span>
            <!-- 实际退货数量 -->
            <template slot="qtyscopedSlots" slot-scope="text, record, index">
              <a-input-number style="width:100%;" v-model="record.qty" :min="0" />
            </template>
            <!-- 差异数 -->
            <!-- <template slot="qtyChaScopedSlots" slot-scope="text, record, index">
              {{ Number(record.deliveryQty - record.receivedQty).toFixed(2) }}
            </template> -->

          </a-table>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { WmsOrderRDetail }  from '@/api/modular/main/WmsStockReturnOrderManage'
import { STable } from '@/components'

export default {
  components: {
    STable
  },
  name: 'WmsReceiptOrderDetailDrawer',
  emits: ['update:visible','postBjData'],
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    row: {
      type: Object,
      default: function() {
        return {}
      }
    }
  },
  data() {
    return {
      loading: false,
      containerStatusData: [],
      list: [],
      columns: [
        {
          dataIndex: 'index',
          title: '序号',
          fixed: 'left',
          width: '60',
          scopedSlots: { customRender: 'index' },
          align: 'center'
        },
        {
          dataIndex:'projectCode',
          title:'项目编号'
        },
        {
          dataIndex: 'materialcode',
          title: '物料编号',
          align: 'center'
        },
        {
          dataIndex: 'materialname',
          title: '物料名称',
          align: 'center'
        },
        
        // {
        //   dataIndex: 'batchno_WMS',
        //   title: '批次',
        //   align: 'center'
        // },
        // {
        //   dataIndex: 'qty',
        //   title: '数量',
        //   align: 'center',
        //   scopedSlots: { customRender: 'qtyscopedSlots' }
        // },
        // {
        //   dataIndex: 'deliveryQty',
        //   title: '送货数量',
        //   align: 'center'
        // },
        {
          dataIndex: 'qty',
          title: '退库数量',
          align: 'center',
          width:'200px',
          // scopedSlots: { customRender: 'qtyscopedSlots' }
        },
        // {
        //   dataIndex: 'chaQty',
        //   title: '差异数',
        //   align: 'center',
        //   scopedSlots: { customRender: 'qtyChaScopedSlots' }
        // },
        // {
        //   dataIndex: 'containerCode',
        //   title: '托盘编码',
        //   align: 'center'
        // },
        // {
        //   title: '状态',
        //   align: 'center',
        //   dataIndex: 'orderStatus',
        //   scopedSlots: { customRender: 'containerStatusscopedSlots' }
        // },
        // {
        //   dataIndex:'unit',
        //   title:'基本单位'
        // },

        // {
        //   dataIndex:'customsUnitName',
        //   title:'单位'
        // },
        // {
        //   dataIndex:'tradeName',
        //   title:'品名'
        // },

           
      ],
      // 分页
      ipagination: {
        current: 1,
        pageSize: 10,
        pageSizeOptions: ['10','20','30','40'],
        showTotal: (total, range) => {
          return range[0] + '-' + range[1] + '共' + total + '条'
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0,
        size:'small'
      },
      selectedRowKeys: [],
    }
  },

  created() {
    const containerStatusOption = this.$options
    this.containerStatusData = containerStatusOption.filters['dictData']('orderdetails_statusenum')
  },
  methods: {
    onClose() {
      this.close()
    },
    close() {
      this.$emit('update:visible', false)
    },
    afterVisibleChange(visible) {
      if (visible) {
        this.initShow()
      } else {
        this.afterClsoe()
      }
    },
    initShow() {
      this.loading = true
      this.getList(() => {
        this.loading = false
      })
    },
    getList(row) {
      WmsOrderRDetail({ id: row.id })
        .then(d => {
          this.list = d.data.rows || []
          this.$emit('update:visible', true)
          // callback && callback(true)
        })
        .catch(() => {
          this.list = []
          this.$emit('update:visible', false)
          // callback && callback(false)
        })
    },
    afterClsoe() {
      this.list = []
    },
    onSelectChange (selectedRowKeys, selectedRows) {
      this.selectedRowKeys = selectedRowKeys
      this.selectedRows = selectedRows
      this.$emit('postBjData', this.selectedRows)
    },
    clearAll(){
      this.selectedRowKeys = []
      this.selectedRows = []
    }
  }
}
</script>

<style lang="less" scoped>
.wms-task-management-detail-div {
  height: 100%;
  overflow: auto;

  .drawer-content {
    padding: 16px;
  }
}
</style>
